// 初始化时调用

import { fileURLToPath } from 'node:url';
import path from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default async function(fastify) {
  // 只支持 mongodb
  // 检查表
  let auto_api_tbs = await fastify.mongo.autoCheck('_db_tables/*.js', __dirname);
  // 自动api
  if (auto_api_tbs.length > 0) {
    await fastify.register(fastify.mongo.autoDBApi(auto_api_tbs), { prefix: '/_db_' });
  }

};
